package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName:SetmealDishMapper
 * @Author:泛微-boliu14
 * @Date:2023/11/6 23:54
 * @Description:SetmealDish
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 根据多个dishId，判断这些菜品中关联套餐的数量
     * @param dishIds
     * @return
     */
    Integer getNumberAssociatedSetmealByIds(List<Long> dishIds);


    /**
     * 根据菜品id查询对应的套餐id
     *
     * @param dishIds
     * @return
     */
    //select setmeal_id from setmeal_dish where dish_id in (1,2,3,4)
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 根据菜品id查询和套餐关联数据
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where dish_id=#{id}")
    List<SetmealDish> getSetmealDishByDishId(Long id);


    /**
     * 批量插入套餐和菜品关联数据
     * @param setmealDishes
     */
    void insertBatch(List<SetmealDish> setmealDishes);


    /**
     * 根据套餐id删除关联表数据
     * @param setmealId
     */
    void deleteBySetmealId(Long setmealId);


    /**
     * 查询与指定套餐的关联数据
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getBySetmealId(Long setmealId);
}
